package com.orchard.xpz.controller.gardenFer;

import com.orchard.xpz.entity.GardenFer.GardenFer;
import com.orchard.xpz.service.gardenFer.GardenFerService;
import com.orchard.xpz.utils.PageResultData;
import com.orchard.xpz.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @TaskCode:
 * @description:
 * @author: minshuai.chen
 * @create: 2022/4/19 11:04
 **/
@RestController
@RequestMapping("/gardenFer")
public class GardenFerController {

    @Autowired
    private GardenFerService gardenFerService;

    @RequestMapping("/getPageList")
    public R<PageResultData<GardenFer>> getPageList(@RequestBody GardenFer gardenPlot){
        return R.success(gardenFerService.getPageList(gardenPlot));
    }

    @RequestMapping("/saveOrUpdate")
    public R<String> saveOrUpdate(@RequestBody GardenFer gardenPlot){
        if (gardenFerService.saveOrUpdate(gardenPlot)){
            return R.success("success");
        }else{
            return R.fail("error");
        }
    }

    @RequestMapping("/delete")
    public R<String> delete(@RequestParam("id") String id){
        if (gardenFerService.deltePlot(id)){
            return R.success("success");
        }else{
            return R.fail("error");
        }
    }
}
